package edu.njucm.herbiv.model

import org.springframework.util.DigestUtils

/**
 * 参数排序后生成唯一的分析号
 * @param params
 * */
fun getAnalysisNo(params: List<String>): String {
    val encodeStr = params.sortedBy { it }.joinToString(separator = ",")
    return DigestUtils.md5DigestAsHex(encodeStr.toByteArray())
}

/**
 * 部分接口存在两个参数，将两个参数都介入生成分析号
 * */
fun getAnalysisNo(params1: List<String>, params2: List<String>, params3: List<String> = emptyList()): String {
    return getAnalysisNo(params1 + params2 + params3)
}

/**
 * @Author ZhouHang
 * @Date 24/5/16 周四
 */
data class FromTcmModel(
    var tcms: List<String>,
    var score: Int
) {
    fun getAnalysisNo(): String {
        return getAnalysisNo(tcms, listOf(score.toString()))
    }
}

data class FromFormulaModel(
    var formulas: List<String>,
    var score: Int
) {
    fun getAnalysisNo(): String {
        return getAnalysisNo(formulas, listOf(score.toString()))
    }
}

data class FromTcmProteinModel(
    var tcms: List<String>,
    var proteins: List<String>,
    var score: Int
) {
    fun getAnalysisNo(): String {
        return getAnalysisNo(tcms, proteins, listOf(score.toString()))
    }
}

data class FromFormulaProtein(
    var formulas: List<String>,
    var proteins: List<String>,
    var score: Int
) {
    fun getAnalysisNo(): String {
        return getAnalysisNo(formulas, proteins, listOf(score.toString()))
    }
}

data class FromProtein(
    var proteins: List<String>,
    var score: Int,
) {
    fun getAnalysisNo(): String {
        return getAnalysisNo(proteins, listOf(score.toString()))
    }
}


data class MessageModel(
    val code: Int,
    val msg: Any
)

data class ResultModel(
    val code: Int,
    val msg: String,
    val resultReq: String = "",
    val echartReq: String = "",
    val cytoReq: String = "",
    val cytoTypeReq: String = ""
)
